package ink.lovejinhu.swardToOffer;

/**
 * @Author: jin
 * @Date: 2021/8/28 22:01
 * @Version: V1.0
 * @Slogan: Great people are not born great, but show their greatness in the process of growing up
 **/
public class Offer_015 {
    public int hammingWeight(int n) {
        return Integer.bitCount(n);
    }

    /**
     * @param n
     * @return
     */
    public int hammingWeight1(int n) {
        int res = 0;
        while (n != 0) {
            res += n & 1;
            n = n >> 1;
            n >>>= 1;


        }
        return res;
    }

    public static void main(String[] args) {
        int i = 2;
        //i >>>= 1;
        i = i >> 1;
        System.out.println(i);
    }
}
